package com.ais.dao;

import java.util.HashMap;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;
import com.ais.vo.Terminal;

@Repository("terminalDao")
public class TerminalDao extends SqlMapClientDaoSupport{
	public String getTerminalNo(){
		return String.valueOf(this.getSqlMapClientTemplate().queryForObject("getNextTerminalNo"));
	}
	/**
	 * 添加终端信息
	 * @param terminal
	 */
	public void addTerminal(Terminal terminal){
		this.getSqlMapClientTemplate().insert("addTerminal", terminal);
	}
	/**
	 * 修改终端信息
	 * @param terminal
	 */
	public void updateTerminal(Terminal terminal){
		this.getSqlMapClientTemplate().update("updateTerminal", terminal);
	}
	/**
	 * 删除终端信息
	 * @param terminalNo
	 */
	public void deleteTerminal(String terminalNo){
		this.getSqlMapClientTemplate().delete("deleteTerminal", terminalNo);
	}
	/**
	 * 获取根据编号单个设备信息
	 * @param terminalNo
	 * @return
	 */
	public Terminal getTerminalByNo(String terminalNo){
		return (Terminal)this.getSqlMapClientTemplate().queryForObject("getTerminalByNo", terminalNo);
	}
	
	/**
	 * 根据条件查询设备信息
	 * @param map
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Terminal> getTerminals(HashMap<String,String>map){
		return this.getSqlMapClientTemplate().queryForList("getTerminals", map);
	}
}
